package com.singfan.common;

import com.singfan.common.util.StringUtil;

/**
 * 服务器环境标识类
 * Author: HanSongHe
 * Date: 2015-07-27 11:42
 * Desc:
 */
public class ServerEnv {
    /**
     * 服务器环境变量标识名字
     */
    public static final String EnvKey = "singfan.env";
    /**
     * 正式线上服务器环境变量标识名字
     */
    public static final String ReleaseKey = "release";

    private static String EnvValue;

    static{
        EnvValue = System.getProperty(EnvKey);

        if(StringUtil.isNullOrEmpty(EnvValue)){
            EnvValue = ReleaseKey;
        }
    }

    /**
     * 获取Java环境中server.env的值
     * @return server.env的值
     */
    public static String getEnv() {
        return EnvValue;
    }

    /**
     * 当前环境是否为正式上线的release环境
     * @return  true:是   false:否
     */
    public static boolean isRelease(){
        return EnvValue.equals(ReleaseKey);
    }
}
